<?php

class ContentType
{
    // 常见的媒体格式
    const TEXT_HTML = "text/static";

    const TEXT_PLAIN = "text/plain";

    const TEXT_XML = "text/xml";

    const TEXT_CSS = "text/css";

    const TEXT_JAVASCRIPT = "text/javascript";

    const IMAGE_JPEG = "image/jpeg";

    const IMAGE_PNG = "image/png";

    const IMAGE_GIF = "image/gif";

    const IMAGE_BMP = "image/bmp";

    const IMAGE_WEBP = "image/webp";

    const IMAGE_ICO = "image/x-icon";

    const IMAGE_SVG = "image/svg+xml";

    // 以application开头的媒体格式类型
    const APPLICATION_X_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded";
    const APPLICATION_JSON = "application/json";
    const APPLICATION_JAVASCRIPT = "application/javascript";
    const APPLICATION_XML = "application/xml";
    const APPLICATION_PDF = "application/pdf";
    const APPLICATION_ZIP = "application/zip";
    const APPLICATION_OCTET_STREAM = "application/octet-stream";

    // 以multipart开头的媒体格式类型
    const MULTIPART_FORM_DATA = "multipart/form-data";

    // 以audio开头的媒体格式类型
    const AUDIO_MPEG = "audio/mpeg";
    const AUDIO_WAV = "audio/wav";
    const AUDIO_WEBM = "audio/webm";
    const AUDIO_OGG = "audio/ogg";


    /**
     * 任何audio类型
     */
    const AUDIO = "audio/*";
    /**
     * 任何video类型
     */
    const VIDEO = "video/*";
    /**
     * 任何image类型
     */
    const IMAGE = "image/*";
    /**
     * 任何text类型
     */
    const TEXT = "text/*";
    /**
     * 任何application类型
     */
    const APPLICATION = "application/*";



    /**
     * 一个静态方法，判断给定的ContentType是否包含某个ContentType值
     * @param string $contentType
     * @param string $value
     * @return bool
     */
    public static function contains(string $contentType,string $value):bool
    {
        return strpos($contentType, $value) !== false;
    }
}